<template>
  <div>
    <div class="operation"><el-button v-if="jurisdiction.addBaseInfo" @click="showDialogDetail('insert')" class="slot-btn-top" type="primary" size="small">新增</el-button></div>
    <el-table :data="tableData" stripe border class="user-table" :height="tableHeight" style="width: 100%;">
      <el-table-column fixed type="index" label="*" sortable align="center" min-width="40"></el-table-column>
      <el-table-column prop="fileName" label="文件名称" sortable min-width="200"></el-table-column>
      <el-table-column prop="fileCode" label="文件编码" sortable min-width="200"></el-table-column>
      <el-table-column prop="versionCode" label="版本号" sortable min-width="200"></el-table-column>
      <el-table-column prop="fileWriterName" label="创建人" sortable min-width="110"></el-table-column>
      <el-table-column prop="createTime" label="创建时间" sortable min-width="170"></el-table-column>
      <el-table-column prop="fileApproverName" label="发布人" sortable min-width="110"></el-table-column>
      <el-table-column prop="approvalTime" label="发布时间" sortable min-width="170"></el-table-column>
      <el-table-column fixed="right" label="操作" sortable align="right" min-width="140">
        <template slot-scope="scope">
          <el-button @click="showDialogDetail('update',scope.row)" type="text" size="small">编辑</el-button>
          <el-button @click="getRecordData(scope.row)" type="text" size="small">记录</el-button>
          <el-button @click="openPrint(scope.row)" type="text" size="small">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagination.currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"></el-pagination>

    <!-- 新增编辑 文件 -->
    <el-dialog :title="dialog.title" width="1200px"  :visible.sync="dialog.isShow" :close-on-click-modal="false" class="bodyNopaddingTop"  v-dialogDrag>
      <el-tabs v-model="dialog.activeName" @tab-click="handleClick">
        <el-tab-pane label="基本信息" name="1">
          <el-form :inline="true"  label-position="right" label-width="120px" :model="dialog.formData" :rules="dialog.rules" ref="fileBaseRef">
            <el-form-item label="文件名称" prop="fileName">
              <el-input v-model="dialog.formData.fileName" class="width220" :disabled="dialog.formData.isLocked===1"></el-input>
            </el-form-item>
            <el-form-item label="文件编码"  prop="fileCode">
              <el-input v-model="dialog.formData.fileCode" class="width220" :disabled="dialog.formData.isLocked===1"></el-input>
            </el-form-item>
            <el-form-item label="版本号"  prop="versionCode">
              <el-input v-model="dialog.formData.versionCode" class="width220" :disabled="dialog.formData.isLocked===1"></el-input>
            </el-form-item>
            <el-form-item label="修订次数">
              <el-input v-model="dialog.formData.updateTimes" disabled class="width220"></el-input>
            </el-form-item>
            <el-form-item label="文件创建人">
              <el-input v-model="dialog.formData.fileWriterName" disabled class="width220"></el-input>
            </el-form-item>
            <el-form-item label="创建日期">
              <el-input v-model="dialog.formData.createTime" disabled class="width220"></el-input>
            </el-form-item>
            <el-form-item label="最后修改日期">
              <el-input v-model="dialog.formData.lastUpdateTime" disabled class="width220"></el-input>
            </el-form-item>
            <el-form-item label="所属文件夹">
              <el-input v-model="dialog.formData.fileGs" disabled class="width220"></el-input>
            </el-form-item>
            <el-form-item label="文件发布人">
              <el-input v-model="dialog.formData.fileApproverName" disabled class="width220"></el-input>
            </el-form-item>
            <el-form-item label="文件是否发布"  >
              <el-select v-model="dialog.formData.isApproval" class="width220" :disabled="dialog.formData.isLocked===1">
                <el-option label="否" value="0"></el-option>
                <el-option label="是" value="1"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="相关部门" prop="fileUseScope">
              <el-select v-model="dialog.formData.fileUseScope" multiple placeholder="请选择" class="width220" :disabled="dialog.formData.isLocked===1">
                <el-option v-for="item in departments" :key="item.id" :label="item.deptName" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
          <el-form  label-position="right" label-width="120px" :model="dialog.formData">
            <el-form-item label="内容" class="form-item-block">
              <div class="vueEditorBox">
                 <VueUeditorWrap v-model="dialog.formData.initialContent" :config="config" :disabled="dialog.formData.isLocked===1"></VueUeditorWrap>
              </div>
            </el-form-item>
            <el-form-item class="form-item-block text-center">
              <el-button  v-if="jurisdiction.addEditApplyInfo&&dialog.formData.isLocked!==1"  @click="submitList" type="primary">确 定</el-button>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <el-tab-pane v-if="dialog.type==='update'" label="附件" name="2">
          <div v-loading="dialog.enclosure.loading">
            <el-form label-position="right" label-width="110px" :model="dialog.enclosure.formData">
              <el-form-item label="选择附件">
                <el-upload class="upload-demo"
                  ref="uploadEnclosure"
                  action="string"
                  :auto-upload="false" 
                  :limit="1" 
                  :http-request="uploadSectionFile">
                  <el-button slot="trigger" size="small" type="primary">上传附件</el-button>
                </el-upload>
              </el-form-item >
              <el-form-item label="文件描述">
                <el-input v-model="dialog.enclosure.formData.fileDesc" type="textarea"></el-input>
              </el-form-item>
              <el-form-item>
                <el-button @click="submitEnclosure" type="primary">提交</el-button>
              </el-form-item>
            </el-form>
          </div>
          <!-- 附件列表 -->
          <h3 class="dialog-plate-title"><span>已上传附件列表</span></h3>
          <el-table :data="dialog.enclosure.enclosureList" stripe border class="user-table">
            <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
            <el-table-column prop="fileName" label="文件名称" sortable min-width="300"></el-table-column>
            <el-table-column prop="uploadPersonName" label="文件上传人" sortable min-width="130"></el-table-column>
            <el-table-column prop="uploadTime" label="文件上传时间" sortable min-width="170"></el-table-column>
            <el-table-column prop="fileDesc" label="文件描述" sortable min-width="400"></el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="right" min-width="90">
              <template slot-scope="scope">
                <el-button v-if="jurisdiction.addEditApplyInfo"  @click="downloadAppendix(scope.row)" type="text" size="small">下载</el-button>
                <el-button @click="deleteAppendix(scope.row)" type="text" size="small"><span class="sub-fn-color3">删除</span></el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>
    <el-dialog title="记录" width="1100px" top="30px" :visible.sync="recordDialg.isShow" :close-on-click-modal="false">
      <el-tabs  v-model="recordDialg.activeName" @tab-click="handleRecordClick">
        <el-tab-pane label="申请修改记录" name="1">
          <!-- 新增按钮 -->
          <el-button v-if="jurisdiction.addEditApplyInfo"  @click="showDialog('insert')" type="primary" icon="el-icon-plus" size="mini">新增申请修改</el-button>
          <!-- 记录列表 -->
          <el-table :data="recordDialg.updateRecordList" stripe border class="user-table" style="width: 100%;">
            <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
            <el-table-column prop="fileCode" label="文件编码" sortable width="140"></el-table-column>
            <el-table-column prop="versionCode" label="版本号" sortable width="120"></el-table-column>
            <el-table-column prop="applicantName" label="申请人" sortable width="110"></el-table-column>
            <el-table-column prop="isTrain" label="是否需要培训" sortable width="80" align="center">
              <template slot-scope="scope">
                <span :class="['table-judge',scope.row.isTrain==='1'?'el-icon-circle-check cl-success':'']"></span>
              </template>
            </el-table-column>
            <el-table-column prop="applyTime" label="申请时间"  sortable min-width="150"></el-table-column>
            <el-table-column prop="approvalResult" label="申请结果"  sortable width="120" align="center">
              <template slot-scope="scope">
                <el-tag type="success" v-if="scope.row.approvalResult==='1'">通过</el-tag>
                <el-tag type="danger" v-else-if="scope.row.approvalResult==='0'">未通过</el-tag>
                <el-tag type="info" v-else>审核中</el-tag>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="right" width="150">
              <template slot-scope="scope">
                <el-button v-if="jurisdiction.addEditApplyInfo"  @click="showDialog('update',scope.row)" type="text" size="small">编辑</el-button>
                <el-button v-if="jurisdiction.auditingApply" type="text" size="small" @click="showDialog('checked',scope.row)">审核</el-button>
                <el-button type="text" size="small" @click="showDialog('historyList',scope.row)">历史记录</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="回收与发放记录" name="2">
          <el-button v-if="jurisdiction.addPrintGrantInfo" @click="showDialog1('insert')" type="primary" icon="el-icon-plus" size="mini">新增发放</el-button>
          <el-table :data="recordDialg.recyclingDistributionList" stripe border class="user-table"  style="width: 100%;">
            <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
            <el-table-column prop="versionCode" label="版本号" sortable width="150"></el-table-column>
            <el-table-column prop="issuerName" label="发放人" sortable width="100"></el-table-column>
            <el-table-column prop="num" label="发放数量" sortable width="70"></el-table-column>
            <el-table-column prop="accepterName" label="接收人" sortable width="100"></el-table-column>
            <el-table-column prop="acceptTime" label="接收时间" sortable width="150"></el-table-column>
            <el-table-column prop="recyclingPersonName" label="回收人" sortable width="100"></el-table-column>
            <el-table-column prop="recyclingTime" label="回收时间" sortable width="150"></el-table-column>
            <el-table-column prop="recyclingVersionCode" label="回收号" sortable width="150"></el-table-column>
            <el-table-column prop="remark" label="备注" sortable min-width="160"></el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="center" width="80">
              <template slot-scope="scope">
                <el-button @click="showDialog1('update',scope.row)" type="text" size="small">回收</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="培训记录" name="3">
          <el-table :data="recordDialg.trainingRecordList" stripe border class="user-table" style="width: 100%;">
            <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
            <el-table-column prop="versionCode" label="版本号" sortable width="150"></el-table-column>
            <el-table-column prop="trainerName" label="培训主持人" sortable width="120"></el-table-column>
            <el-table-column prop="trainTime" label="培训时间" sortable width="150"></el-table-column>
            <el-table-column prop="studyPersons" label="培训参与人" sortable min-width="180"></el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="center" width="80">
              <template slot-scope="scope">
                <el-button @click="showDialog2('update',scope.row)" type="text" size="small">修改</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="版本记录" name="4">
          <el-table :data="recordDialg.versionRecordList" stripe border class="user-table" style="width: 100%;">
            <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
            <el-table-column prop="versionCode" label="版本号" sortable width="180"></el-table-column>
            <el-table-column prop="fileCode" label="文件编码" sortable width="180"></el-table-column>
            <el-table-column prop="issuer" label="发布人" sortable width="130"></el-table-column>
            <el-table-column prop="issueTime" label="发布时间" sortable width="170"></el-table-column>
            <el-table-column prop="versionDesc" label="版本描述" sortable width="800"></el-table-column>
            <el-table-column fixed="right" label="操作" align="right" width="120">
              <template slot-scope="scope">
                <el-button @click="showdialog3('update',scope.row)" type="text" size="small">编辑</el-button>
                <el-button @click="viewDialog(scope.row)" type="text" size="small">查看</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>
    <!-- 新增 修改 申请修改记录弹框 -->
    <!-- 申请修改单记录弹框 -->
    <el-dialog :title="recordDialg.dialog.title" width="1100px" class="bodyNopaddingTop" :visible.sync="recordDialg.dialog.isShow" :close-on-click-modal="false" v-dialogDrag>
      <div v-if="recordDialg.dialog.type==='insert'||recordDialg.dialog.type==='update'">
        <el-form label-position="right" label-width="110px" :model="recordDialg.dialog.formData" ref="applyRecordRef" :rules="recordDialg.dialog.rules" :inline="true">
          <el-form-item label="文件编码"  prop="fileCode">
            <el-input v-model="recordDialg.dialog.formData.fileCode" :disabled="recordDialg.dialog.formData.approvalResult !== '-1'&&recordDialg.dialog.type==='update'"></el-input>
          </el-form-item>
          <el-form-item label="版本号" prop="versionCode">
            <el-input v-model="recordDialg.dialog.formData.versionCode" :disabled="recordDialg.dialog.formData.approvalResult !== '-1'&&recordDialg.dialog.type==='update'"></el-input>
          </el-form-item>
          <el-form-item label="是否需要培训">
            <el-select v-model="recordDialg.dialog.formData.isTrain" :disabled="recordDialg.dialog.formData.approvalResult !== '-1'&&recordDialg.dialog.type==='update'">
              <el-option label="否" value="0"></el-option>
              <el-option label="是" value="1"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="申请人" v-if="recordDialg.dialog.type==='update'">
            <el-input v-model="recordDialg.dialog.formData.applicantName" disabled></el-input>
          </el-form-item>
          <el-form-item label="申请时间"  v-if="recordDialg.dialog.type==='update'">
            <el-input v-model="recordDialg.dialog.formData.applyTime" disabled></el-input>
          </el-form-item>
        </el-form>
        <el-form label-position="right" label-width="110px" :model="recordDialg.dialog.formData" >
          <el-form-item label="申请内容">
            <VueUeditorWrap v-model="recordDialg.dialog.formData.initialContent" :config="config" :disabled="recordDialg.dialog.formData.approvalResult !== '-1'&&recordDialg.dialog.type==='update'"></VueUeditorWrap>
          </el-form-item>
          <el-form-item>
            <el-button v-if="recordDialg.dialog.formData.approvalResult !== '1'" @click="submitUpdateRecord()" type="primary">确 定</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div v-else-if="recordDialg.dialog.type==='checked'">
        <div>
          <h3 class="dialog-plate-title"><span>审核部门列表</span></h3>
          <el-table :data="recordDialg.dialog.checkTableList" stripe border height="300px" class="user-table" style="width: 100%;">
            <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
            <el-table-column prop="deptName" label="审核部门" sortable width="120"></el-table-column>
            <el-table-column prop="approvalerName" label="审核人" sortable width="110"></el-table-column>
            <el-table-column prop="approvalTime" label="审核时间"  sortable width="150"></el-table-column>
            <el-table-column prop="isApproval" label="审核结果" sortable width="110" align="center">
              <template slot-scope="scope">
                  <el-tag type="success" v-if="scope.row.isApproval==='1'">通过</el-tag>
                  <el-tag type="danger" v-else-if="scope.row.isApproval==='0'">未通过</el-tag>
                  <el-tag type="info" v-else>审核中</el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="approvalAdvice" label="审核意见" sortable min-width="120"></el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="center" width="80">
              <template slot-scope="scope">
                <el-button type="text" size="small" @click="showChecked(scope.row)" v-if="!scope.row.isApproval">审核</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div v-if="recordDialg.dialog.checkFormData.deptName">
          <h3 class="dialog-plate-title" style="margin: 10px 0;"><span>审核操作</span></h3>
          <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="110px" :model="recordDialg.dialog.checkFormData">
            <el-form-item label="审核部门">
              <el-input v-model="recordDialg.dialog.checkFormData.deptName" disabled  class="width220"></el-input>
            </el-form-item>
            <el-form-item label="审核结果">
              <el-select v-model="recordDialg.dialog.checkFormData.isApproval" class="width220" >
                  <el-option label="不通过" value="0"></el-option>
                  <el-option label="通过" value="1"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="审核意见" class="form-item-block">
              <el-input v-model="recordDialg.dialog.checkFormData.approvalAdvice"   type="textarea" style="width: 523px;"></el-input>
            </el-form-item>
          </el-form>
          <div class="text-center">
            <el-button @click="submitExamine" type="primary">提交审核</el-button>
          </div>
        </div>
      </div>
      <div v-else-if="recordDialg.dialog.type==='historyList'">
        <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="110px" :model="recordDialg.dialog.historyList">
          <el-form-item label="申请人"><el-input v-model="recordDialg.dialog.historyList.applicantName" disabled></el-input></el-form-item>
          <el-form-item label="申请时间"><el-input v-model="recordDialg.dialog.historyList.applyTime" disabled></el-input></el-form-item>
        </el-form>
        <el-form label-position="right" label-width="110px" :model="recordDialg.dialog.historyList" style="width: 99%;">
          <el-form-item label="申请前内容">
             <VueUeditorWrap v-model="recordDialg.dialog.historyList.beforeContent" :config="config"></VueUeditorWrap>
          </el-form-item>
          <el-form-item label="申请后内容">
            <VueUeditorWrap v-model="recordDialg.dialog.historyList.afterContent" :config="config"></VueUeditorWrap>
          </el-form-item>
        </el-form>
      </div>
    </el-dialog>
    <!-- 发放与回收 弹框 -->
    <el-dialog :title="recordDialg.dialog1.title" width="800px" class="bodyNopaddingTop" :visible.sync="recordDialg.dialog1.isShow" :close-on-click-modal="false" v-dialogDrag>
      <el-form :inline="true"  label-position="right" label-width="110px" :model="recordDialg.dialog1.formData">
        <el-form-item label="发放人">
          <el-input v-model="recordDialg.dialog1.formData.issuerName" disabled class="width220"></el-input>
        </el-form-item>
        <el-form-item label="接收时间">
          <el-input v-model="recordDialg.dialog1.formData.acceptTime" disabled class="width220"></el-input>
        </el-form-item>
        <el-form-item label="发放版本">
          <el-input v-model="recordDialg.dialog1.formData.issueCode" disabled class="width220"></el-input>
        </el-form-item>
        <el-form-item label="发放数量">
          <el-input type="number" v-model="recordDialg.dialog1.formData.num" :disabled="recordDialg.dialog1.type !== 'insert'" class="width220"></el-input>
        </el-form-item>
        <el-form-item label="接收人">
          <el-select v-model="recordDialg.dialog1.formData.accepter" :disabled="recordDialg.dialog1.type !== 'insert'" class="width220">
            <el-option v-for="item in recordDialg.dialog1.receiverList" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <div v-if="recordDialg.dialog1.type !== 'insert'">
          <el-form-item label="回收人">
            <el-input v-model="recordDialg.dialog1.formData.recyclingPersonName" disabled class="width220"></el-input>
          </el-form-item>
          <el-form-item label="回收时间">
            <el-input v-model="recordDialg.dialog1.formData.recyclingTime" disabled class="width220"></el-input>
          </el-form-item>
          <el-form-item label="回收版本">
            <el-input v-model="recordDialg.dialog1.formData.recyclingVersionCode" class="width220"></el-input>
          </el-form-item>
        </div>
        <el-form-item label="备注" class="form-item-block">
          <el-input v-model="recordDialg.dialog1.formData.remark" type="textarea" class="width520"></el-input> 
        </el-form-item>
        <el-form-item class="form-item-block text-center">
          <el-button type="primary" @click="submitRecyclingDistribution">确 定</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
     <!-- 培训记录 弹框 -->
    <el-dialog :title="recordDialg.dialog2.title" width="800px" class="bodyNopaddingTop" :visible.sync="recordDialg.dialog2.isShow" :close-on-click-modal="false" v-dialogDrag>
      <el-form label-position="right" label-width="110px" :model="recordDialg.dialog2.formData">
        <el-form-item label="版本号">
          <el-input v-model="recordDialg.dialog2.formData.versionCode" disabled></el-input>
        </el-form-item>
        <el-form-item label="培训主持人">
          <el-input v-model="recordDialg.dialog2.formData.trainerName" disabled></el-input>
        </el-form-item>
        <el-form-item label="培训时间">
          <el-date-picker v-model="recordDialg.dialog2.formData.trainTime" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间"></el-date-picker>
        </el-form-item>
        <el-form-item label="培训参与人员" class="form-item-block ">
          <el-input v-model="recordDialg.dialog2.formData.studyPersons" type="textarea" class="width520"></el-input>
        </el-form-item>
        <el-form-item class="form-item-block text-center" v-if="jurisdiction.addEditApplyInfo">
          <el-button @click="submitTrainRecord" type="primary" >确 定</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!-- 版本记录 -->
    <el-dialog :title="recordDialg.dialog3.title" width="800px" class="bodyNopaddingTop" :visible.sync="recordDialg.dialog3.isShow" :close-on-click-modal="false" v-dialogDrag>
      <el-form label-position="right" label-width="110px" :model="recordDialg.dialog3.formData">
        <el-form-item label="版本号">
          <el-input v-model="recordDialg.dialog3.formData.versionCode" disabled></el-input>
        </el-form-item>
        <el-form-item label="文件编码">
          <el-input v-model="recordDialg.dialog3.formData.fileCode" disabled></el-input>
        </el-form-item>
        <el-form-item label="发布人">
          <el-input v-model="recordDialg.dialog3.formData.issuer" disabled></el-input>
        </el-form-item>
        <el-form-item label="发布时间">
          <el-input v-model="recordDialg.dialog3.formData.issueTime" disabled></el-input>
        </el-form-item>
        <el-form-item label="版本描述">
          <el-input v-model="recordDialg.dialog3.formData.versionDesc" type="textarea"></el-input>
        </el-form-item>
        <el-form-item class="form-item-block text-center" v-if="jurisdiction.addEditApplyInfo">
          <el-button   @click="submitVersionRecord" type="primary">确 定</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 打印弹框 -->
    <el-dialog title="打印" width="1000px" top="30px" :visible.sync="printDialog.isShow" :close-on-click-modal="false">
      <div>
        <el-button v-if="jurisdiction.addPrintGrantInfo" type="primary" @click="PrintData">打印文件</el-button>
        <div v-if="printDialog.isShow" id="printData" >
          <h2 style="text-align: center;">{{printDialog.printObj.fileName}}</h2>
          <ul class="printData_subTitle" style="overflow: hidden;margin: 10px 0 5px;">
            <li style="list-style:none;float: left;font-size:12px;width: 10%;height: 20px;padding: 0 5px !important;text-align:right;">文件编码：</li>
            <li style="list-style:none;float: left;font-size:12px;width: 20%;height: 20px;padding: 0 5px !important;">{{ printDialog.printObj.fileCode}}</li>
            <li style="list-style:none;float: left;font-size:12px;width: 10%;height: 20px;padding: 0 5px !important;text-align:right;">发布时间</li>
            <li style="list-style:none;float: left;font-size:12px;width: 20%;height: 20px;padding: 0 5px !important;">{{printDialog.printObj.issueTime}}</li>
            <li style="list-style:none;float: left;font-size:12px;width: 10%;height: 20px;padding: 0 5px !important;text-align:right;">版本号：</li>
            <li style="list-style:none;float: left;font-size:12px;width: 20%;height: 20px;padding: 0 5px !important;">{{printDialog.printObj.versionCode}}</li>
          </ul>
          <p style="font-size: 17px;margin: 0;">内容</p>
          <div class="htmlContentBaidu" v-html="printDialog.printObj.initialContent"></div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import baseApi from 'plugins/axios/baseApi.js'
import qualitySystemApi from 'plugins/axios/qualitySystemApi.js'
import VueUeditorWrap from 'vue-ueditor-wrap'
import {mapState} from 'vuex'
export default {
  components:{
    VueUeditorWrap
  },
  data(){
    return {
      orgId:'',
      fileObj:{},/**文件部门对象 */
      dataList:[],
      departments:[],/**相关部门列表 */
      pagination:{
        currentPage: 1,
        pageSize: 10,
        total:0
      },
      jurisdiction:{
        addBaseInfo: false,
        addEditApplyInfo: false,
        addPrintGrantInfo: false,
        auditingApply: false,
        fileRelease: false
      },
      dialog:{
        title:'',
        isShow:false,
        rules:{
          fileName:[{required: true, message: '请输入文件名称', trigger: 'blur' }],
          fileCode:[{required: true, message: '请输入文件编码', trigger: 'blur' }],
          versionCode:[{required: true, message: '请输入版本号', trigger: 'blur' }],
          fileUseScope:[{required: true, message: '请选择至少一个相关部门', trigger: 'blur'}]
        },
        type:'',
        activeName:'1',
        formData:{},
        enclosure:{
          formData:{},
          loading:false,
          enclosureList:[]/**附件列表 */
        }
      },
      config: {
        autoHeightEnabled: false,
        initialFrameHeight: 500,
        initialFrameWidth: '100%',
        // 上传文件接口（这个地址是我为了方便各位体验文件上传功能搭建的临时接口，请勿在生产环境使用！！！）
        autoFloatEnabled: true,　　//是否工具栏可浮动
        initialContent:'请输入内容',   //初始化编辑器的内容,也可以通过textarea/script给值，看官网例子
        autoClearinitialContent:true, //是否自动清除编辑器初始内容，注意：如果focus属性设置为true,这个也为真，那么编辑器一上来就会触发导致初始化的内容看不到了
        BaseUrl: '',
        serverUrl: `${process.env.VUE_APP_API_HOST}/mh/ueditor/config`,
        // serverUrl: `http://192.168.0.83:8891/mh/ueditor/config`,
        
        UEDITOR_HOME_URL: '/ueditor/'
      },
      printDialog:{
        isShow:false,
        printObj:{}
      },
      /**记录弹框 */
      recordDialg:{
        isShow:false,
        activeName:'1',
        formData:{},
        updateRecordList:[],/**申请修改记录列表 */
        recyclingDistributionList:[],/**回收与发放记录列表 */
        trainingRecordList:[],/**培训记录列表 */
        versionRecordList:[],/**版本记录列表*/
        dialog:{ /**申请修改记录弹框 */
          isShow:false,
          type:'',
          title:'',
          rules:{
            fileCode:[{required: true, message: '请输入文件编码', trigger: 'blur' }],
            versionCode:[{required: true, message: '请输入版本号', trigger: 'blur' }]
          },
          formData:{},
          checkTableList:[],/**审核列表 */
          checkFormData:{},/**审核表单 */
          historyList:{},/**历史记录列表 */
        },
        dialog1:{ /**回收与发放记录弹框 */
          isShow:false,
          title:'',
          type:'',
          formData:{},
          receiverList:[]/**接收人列表 */
        },
        dialog2:{ /**培训记录记录弹框 */
          isShow:false,
          title:'',
          type:'',
          formData:{}
        },
        dialog3:{ /**版本记录弹框 */
          isShow:false,
          title:'',
          type:'',
          formData:{}
        },
      }
    }
  },
   watch: {
    $route(){
      this.orgId = this.$route.query.orgId;
      this.getMenuJurisdiction();
      this.getListData();
      this.getDepartmentsList();
    }
  },
  created(){
    
  },
  mounted(){
    this.orgId = this.$route.query.orgId;
    this.getMenuJurisdiction();
    this.getListData();
    this.getDepartmentsList();
  },
  computed:{
    ...mapState({clientHeight:state=>state.common.clientHeight}),
    tableHeight(){
      return this.clientHeight-184;
    },
    tableData(){
      return this.dataList.slice((this.pagination.currentPage-1)*this.pagination.pageSize,this.pagination.currentPage*this.pagination.pageSize)
    }
  },
  methods:{
     /**获取当前菜单当前用户的菜单权限 */
    getMenuJurisdiction(){
      let self = this;
      baseApi.getMenuJurisdiction(168).then(res=>{
        res.content.forEach(item=>{
          self.jurisdiction[item.component] = item.menuShow
        })
      })
    },
    /**获取三级文件列表 */
    getListData(){
      let self = this;
      qualitySystemApi.getFileList(self.orgId).then(res=>{
        self.dataList = res.content;
        self.pagination.total = res.content.length;
      })
    },
    handleSizeChange(size){
      this.pagination.pageSize = size;
    },
    handleCurrentChange(current){
       this.pagination.currentPage = current;
    },
    showDialogDetail(type,row){
      let self = this;
      self.dialog.type = type;
      self.dialog.activeName="1";
      switch(type){
        case 'insert':
          self.dialog.title = '新增'
          self.dialog.isShow = true;
          self.dialog.formData={}
          break;
        case 'update':
          self.dialog.title = '编辑'
          qualitySystemApi.getsjFileDetail(row.fileId).then(res=>{
            self.dialog.isShow = true;
            res.content.initialContent= res.content.initialContent===null?'':res.content.initialContent;
            self.dialog.formData = res.content;
          })
          break;
      }
    },
    /** 获取相关部门列表*/
    getDepartmentsList(){
      let self =this;
      qualitySystemApi.getDepartmentsList().then(res=>{
        self.departments = res.content;
      })
    },
    /**编辑弹框切换 */
    handleClick(tab,event){
      switch(tab.name){
        case '1':
          break;
        case '2':
          this.getEnclosureData()
          break;
      }
    },
    /**获取文件附件列表 */
    getEnclosureData(){
      let self  = this;
      qualitySystemApi.getEnclosureList(self.dialog.formData.fileId).then(res=>{
        self.dialog.enclosure.enclosureList= res.content;
      })
    },
    /***新增和编辑三级文件详情 */
    submitList(){
      let self = this;
      let postData = JSON.parse(JSON.stringify(self.dialog.formData))
       self.$refs.fileBaseRef.validate((valid) => {
        if (valid) {
          qualitySystemApi.insertUpdateSjFile(self.dialog.type,postData,self.orgId).then(res=>{
            self.dialog.isShow = false;
            self.$message.success(`${self.dialog.title}成功！`);
            self.getListData()
          })
        }
      }) 
    },
    /***三级文件点击查看 */
    openPrint(row){
      let self = this;
      qualitySystemApi.getsjFileDetail(row.fileId).then(res=>{
        self.printDialog.isShow = true;
        self.printDialog.printObj=res.content;
        self.printDialog.printObj.issueTime = row.approvalTime
      })
    },
     /**附件提交上传*/
    uploadSectionFile(param){
      let self =this;
      self.dialog.enclosure.loading = true;
      let fileObj = param.file;
      let form =new FormData();
      let postData={
        fileId:self.dialog.formData.fileId,
        fileDesc:self.dialog.enclosure.formData.fileDesc
      };
      form.append('sjAttachment',JSON.stringify(postData));
      form.append('file',fileObj);
      qualitySystemApi.enclosureSjUpload(form).then(res=>{
        self.dialog.enclosure.loading  = false;
        self.$message.success(`附件新增成功`);
        self.dialog.enclosure.formData={};
        self.$refs.uploadEnclosure.clearFiles();
        self.getEnclosureData();
      },error=>{
        self.dialog.enclosure.loading  = false;
      })
    },
    /**点击附件提交*/ 
    submitEnclosure(){
      let self = this;
      if(self.$refs.uploadEnclosure.uploadFiles.length>0){
        self.$refs.uploadEnclosure.submit()
      }else{
         self.$message.error(`请选择需要上传的附件！`)
      }
    },
    downloadAppendix(row){
      window.location.href = qualitySystemApi.downloadSjEnclosure(row.id);
    },
    /**点击删除附件 */
    deleteAppendix(row){
      let self = this;
      self.$confirm('是否删除此附件?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        qualitySystemApi.deleteSjEnclosure(row.id).then(res=>{
          self.$message.success("删除成功！");
          self.getEnclosureData();
        })
      }).catch(() => {});
    },
     /**点击三级文件-记录 */
  getRecordData(row){
    let self = this;
    self.recordDialg.isShow= true;
    self.recordDialg.activeName='1';
    self.recordDialg.formData = row;
    self.getUpdateRecordList()
  },
   /**切换记录tab菜单 */
  handleRecordClick(tab,event){
    switch(tab.name){
      case '1':
        this.getUpdateRecordList();
        break;
      case '2':
          this.getRecyclingDistributionList();
        break;
      case '3':
        this.getTrainingRecordList();
        break;
      case '4':
        this.getVersionRecordList();
        break;
    }
  },
  /**获取申请修改记录列表 */
  getUpdateRecordList(){
    let self = this;
    qualitySystemApi.getSjUpdateRecordList(self.recordDialg.formData.fileId).then(res=>{
      self.recordDialg.updateRecordList=res.content;
    })
  },
  /**获取回收与发放记录列表 */
  getRecyclingDistributionList(){
    let self = this;
    qualitySystemApi.getSjRecyclingDistributionList(self.recordDialg.formData.fileId).then(res=>{
      self.recordDialg.recyclingDistributionList=res.content;
    })
  },
  /**获取培训记录列表 */
  getTrainingRecordList(){
    let self = this;
    qualitySystemApi.getSjTrainingRecordList(self.recordDialg.formData.fileId).then(res=>{
      self.recordDialg.trainingRecordList=res.content;
    })
  },
  /**获取版本记录列表 */
  getVersionRecordList(){
    let self = this;
    qualitySystemApi.getSjVersionRecordList(self.recordDialg.formData.fileId).then(res=>{
      self.recordDialg.versionRecordList=res.content;
    })
  },
  showDialog(type,row){
    let self  = this;
      self.recordDialg.dialog.type = type;
      switch(type){
        case "insert":
          qualitySystemApi.getsjFileDetail(self.recordDialg.formData.fileId).then(res=>{
            self.recordDialg.dialog.isShow = true;
            self.recordDialg.dialog.title = "新增申请修改记录";
            self.recordDialg.dialog.formData={
              fileId: self.recordDialg.formData.fileId,
              initialContent:res.content.initialContent
            }
          })
          break;
        case "update":
          self.recordDialg.dialog.isShow = true;
          self.recordDialg.dialog.title = "编辑申请修改记录";
          self.recordDialg.dialog.formData = JSON.parse(JSON.stringify(row))
          break;
        case 'checked':
          self.recordDialg.dialog.isShow = true;
          self.recordDialg.dialog.title = "审核列表";
          self.recordDialg.dialog.formData = JSON.parse(JSON.stringify(row))
          self.getCheckedList()
          break;
        case 'historyList':
          self.recordDialg.dialog.isShow = true;
          self.recordDialg.dialog.title = "历史记录";
          self.recordDialg.dialog.historyList = JSON.parse(JSON.stringify(row))
          break;
      }
  },
  showDialog1(type,row){
      let self = this;
      self.recordDialg.dialog1.isShow=true;
      self.recordDialg.dialog1.type = type;
      self.getReceiverList();
      switch(type){
        case 'insert':
          self.recordDialg.dialog1.title = '发放'
          self.recordDialg.dialog1.formData={
            fileId: self.recordDialg.formData.fileId
          };
          break;
        case 'update':
          self.recordDialg.dialog1.title = '回收';
          self.recordDialg.dialog1.formData=JSON.parse(JSON.stringify(row));
          self.recordDialg.dialog1.formData.accepter = self.recordDialg.dialog1.formData.accepter?Number(self.recordDialg.dialog1.formData.accepter):null;
          break;
      }
    },
    showDialog2(type,row){
      let self = this;
      self.recordDialg.dialog2.type = type;
      self.recordDialg.dialog2.isShow = true;
      self.recordDialg.dialog2.title = '编辑';
      self.recordDialg.dialog2.formData = JSON.parse(JSON.stringify(row));
    },
    showdialog3(type,row){
      let self = this;
      self.recordDialg.dialog3.type = type;
      self.recordDialg.dialog3.isShow = true;
      self.recordDialg.dialog3.title = '编辑';
      self.recordDialg.dialog3.formData = JSON.parse(JSON.stringify(row));
    },
    /**获取审核列表 */
    getCheckedList(){
      let self = this;
      qualitySystemApi.sjCheckedList(self.recordDialg.dialog.formData.id).then(res=>{
        self.recordDialg.dialog.checkTableList = res.content;
        self.recordDialg.dialog.checkFormData={}
      })
    },
    viewDialog(row){
      this.printDialog.isShow  = true;
      this.printDialog.printObj = row;
      this.printDialog.printObj.initialContent = row.fileContent;
    },
    /**新增修改三级文件申请修改记录 */
    submitUpdateRecord(){
      let self = this;
      self.$refs.applyRecordRef.validate((valid) => {
        if (valid) {
          qualitySystemApi.insertUpdateSjUpdateRecord(self.recordDialg.dialog.type,self.recordDialg.dialog.formData).then(res=>{
            self.recordDialg.dialog.isShow = false;
            self.getUpdateRecordList();
            self.$message.success(`${self.recordDialg.dialog.title}成功`)
          })
        }
      })
    },
    /**显示审核表单 */
    showChecked(row){
      let self = this;
      self.recordDialg.dialog.checkFormData = JSON.parse(JSON.stringify(row));
    },
    /**审核结果提交 */
    submitExamine(){
      let self = this;
      let postData=JSON.parse(JSON.stringify(self.recordDialg.dialog.checkFormData))
      qualitySystemApi.updateSjChecked(postData).then(res=>{
        self.$message.success(`提交成功`)
        self.getCheckedList();
        self.getUpdateRecordList();
        self.getListData();
        self.recordDialg.dialog.checkFormData={};
      })
    },
    /**获取接收人列表 */
    getReceiverList(){
      let self = this;
      qualitySystemApi.getReceiverList().then(res=>{
        self.recordDialg.dialog1.receiverList = res.content;
      })
    },
    /**新增发放-insert 回收-update  提交发放回收记录表单 */
    submitRecyclingDistribution(){
      let self = this;
      let postData=JSON.parse(JSON.stringify(self.recordDialg.dialog1.formData));
      qualitySystemApi.insertUpdateSjRecyclingDistribution(self.recordDialg.dialog1.type,postData).then(res=>{
        self.$message.success(`${self.recordDialg.dialog1.title}成功`);
        self.recordDialg.dialog1.isShow = false;
        self.getRecyclingDistributionList();
      })
    },
    submitTrainRecord(){
      let self = this;
      let postData = JSON.parse(JSON.stringify(self.recordDialg.dialog2.formData))
      qualitySystemApi.updateSjTrainRecord(postData).then(res=>{
        self.$message.success(`${self.recordDialg.dialog2.title}成功`);
        self.recordDialg.dialog2.isShow = false;
        self.getTrainingRecordList();
      })
    },
    /**修改版本记录 */
    submitVersionRecord(){
      let self = this;
      let postData = JSON.parse(JSON.stringify(self.recordDialg.dialog3.formData))
      qualitySystemApi.updateSjVersionRecord(postData).then(res=>{
        self.$message.success(`${self.recordDialg.dialog3.title}成功`);
        self.recordDialg.dialog3.isShow = false;
        self.getVersionRecordList();
      })
    },
  }
 
}
</script>
<style scoped>
.form-item-block .el-form-item__content{
  padding-left:120px;
  box-sizing:border-box;
  position:absolute;
  left:-120px;
}  
</style>